//Build = 2006.05.10
var _XMLMNL_VER		= "3.01.60";

/***********
** 共通変数
***********/
var _naviname = _getBrowserName();

// TOC - XML
if (document.implementation && document.implementation.createDocument) {
	var _xmltoc = document.implementation.createDocument("", "", null);
	_xmltoc.async = false;
	_xmltoc.selectNodes = myselectNodes;
	_xmltoc.selectSingleNode = myselectSingleNode;
} else if (window.ActiveXObject) {
	var _xmltoc = new ActiveXObject('Microsoft.XMLDOM');
	_xmltoc.async = false;
}

// TOC - XML
if (document.implementation && document.implementation.createDocument) {
	var _xmltoc2 = document.implementation.createDocument("", "", null);
	_xmltoc2.async = false;
	_xmltoc2.selectNodes = myselectNodes;
	_xmltoc2.selectSingleNode = myselectSingleNode;
} else if (window.ActiveXObject) {
	var _xmltoc2 = new ActiveXObject('Microsoft.XMLDOM');
	_xmltoc2.async = false;
}

// TOC -XSL
if (document.implementation && document.implementation.createDocument) {
	var _xsltoc = document.implementation.createDocument("", "", null);
	_xsltoc.async = false;
} else if (window.ActiveXObject) {
	var _xsltoc = new ActiveXObject('Microsoft.XMLDOM');
	_xsltoc.async = false;
}

/***********
** 共通関数
***********/
function _getLocationSearch() {
	var qstr = new Array();
	if (location.search.length > 1) {
		var q_array = location.search.substr(1).split("&");
		for (var n in q_array) {
			qstr.push(q_array[n].split("="));
		}
	}
	return qstr;
}

function _getBrowserName() {
	var str = navigator.appName.toUpperCase();
	if (str.indexOf("NETSCAPE") >= 0) return ("NS");
	if (str.indexOf("EXPLORER") >= 0) return ("IE");
	return ("UNKNOWN");
}

function _getBrowserLang() {
	if (_naviname == "IE") {
		//return navigator.browserLanguage;
		//return navigator.systemLanguage;
		return navigator.userLanguage;
	} else if (_naviname == "NS"){
		return navigator.language.split("-")[0];
	}
}

function _getCookie(sName) {
	var cookieArray = document.cookie.split('; ')
	for (var i = 0 ; i < cookieArray.length ; i++) {
		var aCrumb = cookieArray[i].split('=')
		if ((sName == aCrumb[0]) && (aCrumb[1] != null)) {
			return unescape(aCrumb[1])
		}
	}
	return '';
}

function _selectNodes(xmlobj, xpath) {	// for Firefox Only
	var context = xmlobj.documentElement;
	var type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
	var resolver = xmlobj.createNSResolver(xmlobj.documentElement);
	var expression = xmlobj.createExpression(xpath, resolver);
	var result = expression.evaluate(context, type, null);
	return result;
}

function myselectNodes() {		// for Firefox Only
	if (_naviname == "NS") {
		var context = this.documentElement;
		if (this.documentElement == null) {
			return null;
		}
		var type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
		var resolver = this.createNSResolver(this.documentElement);
		var expression = this.createExpression(myselectNodes.arguments[0], resolver);
		var result = new Object();
		result = expression.evaluate(context, type, null);
		result.length = result.snapshotLength;
		result.item = result.snapshotItem;
		return result;
	}
}

function myselectSingleNode() {		// for Firefox Only
	if (_naviname == "NS") {
		var context = this.documentElement;
		if (this.documentElement == null) {
			return null;
		}
		var type = XPathResult.FIRST_ORDERED_NODE_TYPE;
		var resolver = this.createNSResolver(this.documentElement);
		var expression = this.createExpression(myselectSingleNode.arguments[0], resolver);
		var result = new Object();
		result = expression.evaluate(context, type, null);
		result.text = result.singleNodeValue.firstChild.nodeValue;
		if (result != null) {
			if (result.hasChildNode) {
				result.text = result.firstChild.nodeValue;
			} else {
				result.text = "";
			}
		}
		return result;
	}
}

function _xmltransform(xmlobj, xslobj, params, targetid) {
	if (_naviname == "NS") {
		var xslProc = new XSLTProcessor();
		xslProc.importStylesheet(xslobj);
		for (id in params) {
			xslProc.setParameter(null, id, params[id]);
		}
		if (xmlobj != null) {
			var xmldocment = xslProc.transformToDocument(xmlobj);
			if (targetid != "") {
				document.getElementById(targetid).innerHTML = xmldocment.documentElement.innerHTML;
			} else {
				return "<html>" + xmldocment.documentElement.innerHTML + "</html>";
			}
		}
	} else if (_naviname == "IE") {
		for (id in params) {
			var paramNode = xslobj.getElementsByTagName("xsl:param[@name='" + id + "']");
			paramNode.item(0).text = params[id];
		}
		if (xmlobj != null) {
			if (targetid != "") {
				eval(targetid).innerHTML = xmlobj.transformNode(xslobj);
			} else {
				return xmlobj.transformNode(xslobj);
			}
		}
	}
}
